<template>
	<div class="newsInfo">
		<h3 class="title">{{title}}</h3>
		<p class="subtitle">
			<span>发表时间：{{add_time}}</span>
			<span>点击：{{click}}次</span>
		</p>
		<hr>
		<div class="content">
			{{content}}
		</div>

	<!-- 评论子组件 -->
	<comment></comment>
	</div>
</template>

<script type="text/javascript">
	import comment from './subcomponents/comment.vue'
	export default {
		data() {
			return {
				id: this.$route.query.id,
				title: '',
				content: '',
				click: '',
				add_time: ''
			}
		},
		methods: {
			getNewsInfo() {
				this.$http.get('home/newsInfo?id=' + this.id)
				.then(data => {
					data = JSON.parse(data.body.resBody.data)[0]
					this.title = data.title;
					this.content = data.content;
					this.click = data.click;
					this.add_time = data.add_time;
				})
			}
		},
		created() {
			this.getNewsInfo();
		},
		components: {
			comment
		}
	}
</script>

<style lang="less" scoped>
	.newsInfo{
		padding: 0 4px;
		.title{
			font-size: 16px;
			text-align: center;
			margin: 15px 0;
		}
		.subtitle{
			font-size: 14px;
		}
		.content{
			padding: 5px 5px;
			font-size: 14px;
		}
	}
</style>